//
//  DetailListTableViewCell.m
//  sooc-ios_new
//
//  Created by houshijia on 16/3/20.
//  Copyright © 2016年 xuguangChao. All rights reserved.
//
#define Width (270*0.383*SIZEWIDTH/414)
#import "DetailListTableViewCell.h"
#import "ClassDetailModel.h"
@implementation DetailListTableViewCell

- (void)awakeFromNib {
    // Initialization code
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
       
        //图片
        _titleImage = [[UIImageView alloc]init];
        _titleImage.layer.borderWidth = 1;
        _titleImage.layer.borderColor = COLOR(247, 247, 247, 1.0).CGColor;
        _titleImage.image = [UIImage imageNamed:@"page_1.png"];
        [self.contentView addSubview:_titleImage];
        
        [_titleImage  mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.equalTo(self.contentView).with.offset(39*Bili);
            make.left.equalTo(self.contentView).with.offset(33*Bili);
            make.bottom.equalTo(self.contentView).with.offset(-39*Bili);
            make.right.equalTo(self.contentView.mas_centerX).with.offset(-126*Bili);
            
        }];
        
        
        
        //小锁的图片
        _lockImg = [[UIImageView alloc]init];
        [_titleImage addSubview:_lockImg];
        _lockImg.image = [UIImage imageNamed:@"课程加密"];
        [_lockImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.and.height.mas_equalTo(@(20));
            make.bottom.equalTo(_titleImage);
            make.right.equalTo(_titleImage);
        }];
        
        _lockImg.hidden = YES;
        
        
        //标题
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.text = @"创业微访谈";
        _titleLabel.font = NormalFont(40);
        //        _titleLabel.numberOfLines = 2;
        
        _titleLabel.textColor = Color333333;
        [self.contentView addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleImage.mas_top);
            make.left.equalTo(_titleImage.mas_right).offset(33*Bili);
            make.right.equalTo(self.contentView.mas_right).offset(-33*Bili);
            make.width.mas_equalTo(@(32));
        }];
        
        
        self.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        self.titleLabel.numberOfLines = 2;
        
        //学习人数
        _peopleLable = [UILabel new];
        _peopleLable.text = @"1000000人学习";
        _peopleLable.font = NormalFont(32);
        _peopleLable.textAlignment = NSTextAlignmentRight;
        _peopleLable.textColor = Color999999;
        _peopleLable.numberOfLines = 0;
        [_peopleLable sizeToFit];
        [self.contentView addSubview:_peopleLable];
        
        [_peopleLable mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.right.equalTo(self.contentView).with.offset(-33*Bili);
            make.bottom.equalTo(_titleImage.mas_bottom).with.offset(4);
            make.size.mas_equalTo(CGSizeMake(100, 20));
            
        }];

        
        
        _smallImage = [[UIImageView alloc]init];
        _smallImage.image = [UIImage imageNamed:@"我的-课程发布人"];
        [self.contentView addSubview:_smallImage];
        
        [_smallImage mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(_titleImage.mas_right).with.offset(33*Bili);
            make.bottom.equalTo(_titleImage.mas_bottom).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(48*Bili, 48*Bili));
            
        }];
        
        _nameLabel = [UILabel new];
        _nameLabel.text = @"李老师";
        _nameLabel.font = NormalFont(32);
        _nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        _nameLabel.textColor = Color999999;
        [self.contentView addSubview:_nameLabel];
        
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(_smallImage.mas_right).with.offset(24*Bili);
            make.bottom.equalTo(_smallImage.mas_bottom).with.offset(4);
            make.height.mas_equalTo(20);
            make.right.equalTo(_peopleLable.mas_left).offset(5);
            
        }];
        

    }
    
    return self;
}

- (void)setMyModel:(ClassDetailModel *)myModel{
    
    _myModel = myModel;
    
    [self.titleImage sd_setImageWithURL:[NSURL URLWithString:myModel.kcfm] placeholderImage:nil options:SDWebImageCacheMemoryOnly];
    _titleLabel.text = _myModel.kcmc;

    _titleLabel.lineSpace = 10*Bili;
    
    CGRect h = [self.titleLabel getLableHeightWithMaxWidth:SIZEWIDTH - ((SIZEWIDTH/2 - 126*Bili) + 66*Bili)];
    
    _titleLabel.frame = CGRectMake(CGRectGetMaxX(self.titleImage.frame)+33*Bili, 39*Bili, h.size.width, h.size.height);
    
    self.nameLabel.text = myModel.kcjs;
    
    self.peopleLable.text = [NSString stringWithFormat:@"%@人学习", myModel.kcrs];

    
}
+ (DetailListTableViewCell *)cellWithTableView:(UITableView *)tableView{
    
    static NSString *ident = @"cell";
    
    DetailListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ident];
    
    if (!cell) {
        
        cell = [[DetailListTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ident];
        
    }
    return cell;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
